#!/bin/bash

appName=CavaOpenClient
dstDir=./release
target=CavaOpenClient

function del()
{
    rm -rf build

    rm -rf dist

    rm -rf ${appName}.spec
    
    rm -rf ${dstDir}/${target}
    rm -rf ${dstDir}/${target}.tar.gz
}

del
pyinstaller --nowindowed --onefile ./src/${appName}.py
cp -rf dist/${appName} ./
del


mkdir -p ${dstDir}/${target}
mv  ${appName} ${dstDir}/${target}
cp -rf ./src/config.xml ${dstDir}/${target}
#cp -rf start.sh ${target}
cp -rf start.sh ${dstDir}/${target}
#cp -rf pem ${target}
git log -1 . > ${dstDir}/${target}/version.info

cd ${dstDir}
tar -czvf ${target}.tar.gz ${target}
rm -rf ${target}
cd ..

echo "pack ${appName} to ${dstDir}/${target}.tar.gz succeed."
